package com.liuluo.homework1025hou.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liuluo.homework1025hou.domain.Student;
import com.liuluo.homework1025hou.mapper.StudentMapper;
import com.liuluo.homework1025hou.service.StudentServiceJava;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImplJava extends ServiceImpl<StudentMapper, Student> implements StudentServiceJava {

    @Override
    public List<Student> getByGender(String gender) {
        LambdaQueryWrapper<Student> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Student::getGender,gender);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public List<Student> getBetweenBirthday(String birthdayStart, String birthdayEnd) {
        LambdaQueryWrapper<Student> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.between(Student::getBirthday,birthdayStart, birthdayEnd);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public List<Student> getLikeName(String likeName) {
        LambdaQueryWrapper<Student> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(Student::getName,likeName);
        return baseMapper.selectList(queryWrapper);
    }
}
